home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / OpenDoc 1.2b2c1 / OpenDoc / OpenDoc Utilities / Interfaces / InfoUtil.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-01  |  12.6 KB  |  353 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        InfoUtil.h
  3.  
  4.     Contains:    function declarations Info getters & setters
  5.  
  6.     Owned by:    Nick Pilch
  7.  
  8.     Copyright:    © 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.         <11>      10/10/96    RA        1343748: Pass around thePartSU so we can
  13.                                     use a preferred editor string for NoPart.
  14.         <10>     10/7/96    RA        1343814: Pass around thePartSU so we can
  15.                                     use a preferred kind string for NoPart
  16.          <9>     9/13/96    EL        1385235: Kind Menu should dispaly every
  17.                                     stored kind as active.
  18.          <8>      7/8/96    EL        1364853: Add ODSetPartNameReturnError to do
  19.                                     set part name but get error code back.
  20.          <7>     6/12/96    RA        1301627 : ODGetIconFamily now looks in all
  21.                                     volume DTDB's ; added StVolumeLoop util
  22.                                     class.
  23.          <6>      6/5/96    EL        1355529: Move InitKindsPopUp from Info.cpp
  24.                                     to here for sharing, add parameters for
  25.                                     AddTypesToMenu.
  26.          <5>      6/4/96    EL        1279544: Move GetTypeListItem from
  27.                                     TransDlg.cpp to InfoUtil.cpp.
  28.          <4>     5/31/96    jpa        T10012: Added ODGetIconFilePlatformCreator.
  29.          <3>     5/24/96    jpa        1.1MRD: pragma internal eliminates NOPs.
  30.          <2>    .04.1996    NP        1330731: Don't use stationery property
  31.                                     anymore.
  32.  
  33.     To Do:
  34.     In Progress:
  35.         
  36. */
  37.  
  38. #ifndef _INFOUTIL_
  39. #define _INFOUTIL_
  40.  
  41. #ifndef _ODTYPES_
  42. #include <ODTypes.h>
  43. #endif
  44.  
  45. #ifndef __CONTROLS__
  46. #include <Controls.h>
  47. #endif
  48.  
  49. #ifndef SOM_ODWindowState_xh
  50. #include <WinStat.xh>
  51. #endif
  52.  
  53. #ifndef SOM_ODNameSpaceManager_xh
  54. #include "NmSpcMg.xh"
  55. #endif
  56.  
  57. #ifndef _ORDCOLL_
  58. #include "OrdColl.h"
  59. #endif
  60.  
  61. //==============================================================================
  62. // Theory of Operation
  63. //==============================================================================
  64.  
  65. //==============================================================================
  66. // Constants
  67. //==============================================================================
  68.  
  69. //==============================================================================
  70. // Scalar Types
  71. //==============================================================================
  72.  
  73. //==============================================================================
  74. // Classes used by this interface
  75. //==============================================================================
  76.  
  77. class    ODFrame;
  78. class    ODStorageUnit;
  79. class    ODPart;
  80. class    ODPersistentObject;
  81. class    ODTypeList;
  82. class    EditorSet;
  83. class    ODSession;
  84. class    PlatformFile;
  85.  
  86. //==============================================================================
  87. // Info functions
  88. //==============================================================================
  89.  
  90. #ifdef _OD_IMPL_SHARE_UTILS_
  91. #pragma import on
  92. #elif defined(PRAGMA_INTERNAL_SUPPORTED)
  93. #pragma internal on
  94. #endif
  95.  
  96. extern "C" {
  97.  
  98.  
  99.  
  100. //-------------------------------------------------------------------------------------
  101. // Persistent Object Property getters and setters
  102. // Note: 
  103. //  all Getters expect you to pass in a buffer to be filled 
  104. //  or kODNULL which causes it to create one for you
  105. //  all Setters do NOT consume what you pass in, so it is safe to pass in
  106. //     a reference to your internal structures.  They are only accessed for the duration
  107. //     of the Setter API call.
  108. // These conventions were adopted to reduce memory allocation/deallocation.
  109. //-------------------------------------------------------------------------------------
  110.  
  111. ODULong        ODGetCreationDate(Environment* ev, 
  112.                 ODStorageUnit* su);
  113. void        ODSetCreationDate(Environment* ev, 
  114.                 ODStorageUnit* su,
  115.                 ODTime dateTime);
  116.                 
  117. ODULong        ODGetModificationDate(Environment* ev, 
  118.                 ODStorageUnit* su);
  119. void        ODSetModificationDate(Environment* ev, 
  120.                 ODStorageUnit* su,
  121.                 ODTime dateTime);
  122.                 
  123. ODIText*    ODGetModifiedBy(Environment* ev, 
  124.                 ODStorageUnit* su,ODIText* userName);
  125. void        ODSetModifiedBy(Environment* ev, 
  126.                 ODStorageUnit* su, ODIText* userName);
  127.  
  128.  
  129. ODStorageUnit* ODGetSUFromPstObj(Environment* ev, ODPersistentObject* pstobj);
  130.  
  131. ODIText*    ODGetPOComments(Environment* ev,  ODPart* part, ODIText* comments);
  132. void        ODSetPOComments(Environment* ev, ODPart* part, ODIText* comments);
  133.  
  134. ODIconFamily    ODGetPOIconFamily(Environment* ev,
  135.                     ODPart* part);
  136. void        ODSetPOIconFamily(Environment* ev, 
  137.                     ODPart* part, ODIconFamily iconFamily,
  138.                     ODBoolean deleteOtherPlatformIcons =kODTrue);
  139.  
  140. ODULong        ODGetPOSize(Environment* ev, 
  141.                 ODPersistentObject* pstobj);
  142. ODID        ODGetPOID(Environment* ev, 
  143.                 ODPersistentObject* pstobj);
  144.  
  145. // Note: the next two functions are lowlevel functions for directly setting
  146. // and getting the name property of persistent objects.  
  147. // If you are dealing with a part, please use ODGetPartName & ODSetPartName
  148. // in order to make sure the right thing happens with respect to 
  149. // the document file, titles of windows etc.  -Tantek
  150. ODIText*    ODGetPOName(Environment* ev, 
  151.                         ODPersistentObject* pstobj,ODIText* name);
  152. void        ODSetPOName(Environment* ev, 
  153.                         ODPersistentObject* pstobj,ODIText* name);
  154.  
  155. // The next function is used when the persistent object is not internalized yet. - Vincent
  156. void        ODSetPONameUsingSU(Environment* ev, ODStorageUnit* su, ODIText* name);
  157.  
  158. //-------------------------------------------------------------------------------------
  159. // Part only Property getters and setters
  160. //-------------------------------------------------------------------------------------
  161.  
  162. ODIText*    ODGetPartName(Environment* ev, 
  163.                 ODFrame* frame,ODIText* name);
  164.         // Returns the name of the part of the frame passed in.
  165.  
  166. ODBoolean    ODSetPartName(Environment* ev, 
  167.                 ODFrame* frame, ODIText* name, DescType replaceOption);
  168.         // Renames the part of the frame passed in.
  169.         // Returns whether or not it succeeded.
  170.         // The frame helps more easily determine whether
  171.         // the part is the root part of the document or not.
  172.         // For example, renaming the root part of the document could fail
  173.         // if there was a file with the same name and the user canceled the
  174.         // "Replace?" dialog.
  175.  
  176. void        ODRenamePartWindows( Environment *ev, ODSession *session, ODPart *part,
  177.                                  ODIText *oldName, ODIText *name );
  178.         // Renames windows with 'part' as their root part. Subroutine used
  179.         // by ODSetPartName; not usually needed for other purposes (although
  180.         // the Shell does use it.)
  181.  
  182.  
  183. ODIText*    ODGetComments(Environment* ev,  ODFrame* frame, ODIText* comments);
  184. void        ODSetComments(Environment* ev, ODFrame* frame, ODIText* comments);
  185.  
  186. ODName*        ODGetCategory(Environment* ev, ODPart* part, ODNameSpaceManager* nsm);
  187. ODName*        ODGetCatFromPartSU(Environment* ev, ODStorageUnit* su, ODNameSpaceManager* nsm);
  188. ODName*        ODGetCatFromKind(Environment* ev, ODType kind, ODNameSpaceManager* nsm);
  189.  
  190. ODType        ODGetKind(Environment* ev, ODPart* part);
  191. ODType        ODGetKindFromPartSU(Environment* ev, ODStorageUnit* su);
  192. ODPlatformType ODGetIconFilePlatformTypeFromPartSU(Environment* ev, 
  193.         ODStorageUnit* su);
  194. ODPlatformType ODGetIconFilePlatformCreator( Environment *ev, ODPart *part );
  195. ODPlatformType ODGetIconFilePlatformCreatorFromPartSU( Environment *ev, ODStorageUnit *su );
  196.  
  197.  
  198. ODIconFamily    ODGetIconFamily(Environment* ev,
  199.                     ODFrame* frame);
  200. void        ODSetIconFamily(Environment* ev, 
  201.                     ODFrame* frame, ODIconFamily iconFamily,
  202.                     ODBoolean deleteOtherPlatformIcons =kODTrue);
  203.  
  204. ODBoolean    ODGetIsStationery(Environment* ev, 
  205.                 ODFrame* frame);
  206. void        ODSetIsStationery(Environment* ev, 
  207.                 ODFrame* frame, ODBoolean isStationery);
  208.  
  209. //ODBoolean        ODGetSUIsStationery(Environment* ev, ODStorageUnit* su);
  210. //void        ODSetSUIsStationery(Environment* ev, 
  211. //                ODStorageUnit* su, ODBoolean isStationery);
  212.  
  213. //-------------------------------------------------------------------------------------
  214. // Frame only Property getters and setters
  215. //-------------------------------------------------------------------------------------
  216. // see Frame.idl
  217.  
  218.  
  219. //-------------------------------------------------------------------------------------
  220. // General Utility functions
  221. //-------------------------------------------------------------------------------------
  222.  
  223. void SetAllWindowShowLinks(Environment* ev, ODWindowState* winState, ODBoolean showLinks);
  224. PlatformFile*    ODGetFileIfRoot(Environment* ev, ODFrame* frame);
  225.  
  226. ODBoolean    ODAskUserReplace(Environment* ev,
  227.                             ODSession* session);
  228. // Pass in the name in question via ParamText(^0).
  229.  
  230. //-------------------------------------------------------------------------------------
  231. // Editor and Kind popup Menu manipulation functions
  232. // copied from LinkDlgs.cpp (!with changes by TÇ and CG)
  233. //-------------------------------------------------------------------------------------
  234. // private by convention.
  235.  
  236. void InitKindsPopup (     ODTypeList* kindList,
  237.                                 ODType theKind,
  238.                                 ControlHandle itemHandle,
  239.                                 ODSShort valueCount,
  240.                                 ODSShort* currentKindItem,
  241.                                 MenuHandle kindMenu,
  242.                                 ODSShort* translateItem,
  243.                                 ODSession* session,
  244.                                 ODStorageUnit* thePartSU = kODNULL);
  245. void AddTypesToMenu(ODTypeList* kindList, 
  246.                                 MenuHandle kindMenu,
  247.                                 ODType defaultKind,
  248.                                 ODSShort valueCount,
  249.                                 ODSShort* currentKindItem,
  250.                                 ODSession* session,
  251.                                 ODStorageUnit* thePartSU = kODNULL);
  252. ODUShort EnableTypesInMenu(ODTypeList* typeList,
  253.                                 MenuHandle kindMenu,
  254.                                 ODEditor editor,
  255.                                 ODNameSpaceManager* nsm);
  256. ODBoolean SetupEditorMenu(ODType kind,
  257.                                 EditorSet* editorList,
  258.                                 MenuHandle editorMenu, 
  259.                                 ControlHandle popupCtlHndl, 
  260.                                 ODSession* session,
  261.                                 ODStorageUnit* thePartSU = kODNULL);
  262. void AddEditorsToMenu(EditorSet* editorList,
  263.                                 MenuHandle editorMenu, 
  264.                                 ODSession* session,
  265.                                 ODStorageUnit* thePartSU = kODNULL);
  266. void ContentValueTypes(ODStorageUnit* contentSU, ODTypeList* typeList);
  267. ODEditor GetThisEditorFromList(ODSShort editorIndex, EditorSet* editorList);
  268. ODType GetThisKindFromList(ODSShort kindItem, ODTypeList* kindList);
  269. ODSShort IndexOfEditorInList(EditorSet* editorsList, ODEditor editor);
  270. ODSShort IndexOfKindInList(ODTypeList* kindList, ODType kind);
  271. void TranslateValueTypes(ODTypeList* kindList,
  272.                                 ODTypeList* translateToList,
  273.                                 OrderedCollection* translateFromList,
  274.                                 ODSession* session);
  275. void AddTranslationKindToMenu(ODType        kind, 
  276.                                 MenuHandle    kindMenu,
  277.                                 short        item,
  278.                                 ODBoolean    insert,
  279.                                 ODSession*    session);
  280. ODType GetTypeListItem(ODTypeList* typeList, ODUShort index);
  281.  
  282. ODIconFamily ODGetIconSuiteFromDesktopDB(ODPlatformType fileType,ODPlatformType fileCreator);
  283. ODIconFamily BuildIconSuiteFromDesktop(short DTRefNum,ODPlatformType fileType,ODPlatformType fileCreator);
  284. ODError    ODSetPartNameReturnError(Environment* ev, ODFrame* frame, ODIText* name, DescType replaceOption);
  285. }    // End of extern "C" {
  286.  
  287. //==============================================================================
  288. //    StVolumeLoop
  289. //==============================================================================
  290.  
  291. class StVolumeLoop
  292. {
  293. public:
  294.     //——————————————————————————————————————————————————————————————————————
  295.     //    Construction and destruction
  296.     //——————————————————————————————————————————————————————————————————————
  297.     StVolumeLoop();
  298.         // Use the system volume for the initial pass
  299.     
  300.     StVolumeLoop(short inInitialVolumeRef);
  301.     
  302.     //——————————————————————————————————————————————————————————————————————
  303.     //    Iteration
  304.     //——————————————————————————————————————————————————————————————————————
  305.     Boolean NextVolume(short& outVolume);
  306.     
  307.     //——————————————————————————————————————————————————————————————————————
  308.     //    Volume passes
  309.     //——————————————————————————————————————————————————————————————————————
  310.     enum EPass { kInitialPass, kLocalPass, kRemotePass, kDonePass };
  311.  
  312.     EPass GetCurrentVolumePass();
  313.     
  314. private:
  315.     //——————————————————————————————————————————————————————————————————————
  316.     //    Utility functions
  317.     //——————————————————————————————————————————————————————————————————————
  318.     void SetupNextVolumePass();
  319.     
  320.     static Boolean IsRemoteVolume(HParamBlockRec& inHFSParams);
  321.     
  322. private:
  323.     //——————————————————————————————————————————————————————————————————————
  324.     //    Data members
  325.     //——————————————————————————————————————————————————————————————————————
  326.     short        mInitialVRefNum;    
  327.     EPass        mVolumePass;
  328.     short        mVolumeIndex;
  329. };
  330.  
  331. //==============================================================================
  332. //    StVolumeLoop inlines
  333. //==============================================================================
  334.  
  335. //——————————————————————————————————————————————————————————————————————————————
  336. //    StVolumeLoop::GetCurrentVolumePass
  337. //——————————————————————————————————————————————————————————————————————————————
  338. inline StVolumeLoop::EPass 
  339. StVolumeLoop::GetCurrentVolumePass()
  340. {
  341.     return mVolumePass;
  342. }
  343.  
  344. //——————————————————————————————————————————————————————————————————————————————
  345.  
  346. #ifdef _OD_IMPL_SHARE_UTILS_
  347. #pragma import off
  348. #elif defined(PRAGMA_INTERNAL_SUPPORTED)
  349. #pragma internal reset
  350. #endif
  351.  
  352. #endif // _INFOUTIL_
  353.